/*
 * @Description: 测试类
 * 
 * 
 * @Author: rendc
 * 
 * @Date: 2025-08-06 14:19:09
 * 
 * @LastEditors: rendc
 * 
 * @LastEditTime: 2025-08-06 14:24:05
 */
public class Test {
  public static void main(String[] args) {
    // System.out.println("hello");
    // 实例化匿名内部类对象
    Animal animal = new Animal() {

      @Override
      public void eat() {
        System.out.println(super.getName() + "吃东西");
      }

      @Override
      public void sleep() {
        System.out.println(super.getName() + "睡大觉");
      }

    };
    animal.eat();
    animal.sleep();
    // 实例化匿名内部类对象+构造器传参
    Animal animal2 = new Animal("汤姆🐱") {

      @Override
      public void eat() {
        System.out.println(super.getName() + "吃东西");
      }

      @Override
      public void sleep() {
        System.out.println(super.getName() + "睡大觉");
      }

    };
    animal2.eat();
    animal2.sleep();
  }
}